import React, { Component } from 'react';

import { Table, Button,  message,Cascader } from 'antd';
import './index.css';

// 引入接口
import { _examList } from '@/api/examList';
import { _examadd } from '@/api/examadd';
const { Column } = Table;
const options = [
	{
		value: 'zhejiang',
		label: 'Zhejiang',
	},
	{
		value: 'jiangsu',
		label: 'Jiangsu',
	},
  ];
//班级
function Class(props: any) {
  let str = '考试班级';

  return <span>{str}</span>;
}

export default class index extends Component {
  state = {
    list: [], //总数居
    exam_name:''

  };

  render() {
    
    // 解构数据
    const { list } = this.state;
    function onChange(value: any) {
      console.log(value);
  }
    return (
      
      <div>
        <h2>试卷列表</h2>
        <div className="box">
          <div className="example-input">
                    <span>考试类型：</span><Cascader options={options} onChange={onChange} changeOnSelect />
          </div>
          <div className="example-input">
                    <span>课程：</span><Cascader options={options} onChange={onChange} changeOnSelect />
          </div>

          <div> <Button type="primary">查询</Button></div>
        </div>
        <Table className="table" dataSource={list} rowKey={'stationVersionId'}>
          <Column title="试卷信息" dataIndex="title" />
          <Column
            title="班级"
            dataIndex="grade_name"
            render={(rew) => {
              return (
                <div>
                  <Class></Class>
                  <br />
                  <span>{rew.lastItem}</span>
                </div>
              );
            }}
          />
          <Column title="创建人" dataIndex="taskCount" />
          <Column title="开始时间" dataIndex="start_time" />
          <Column title="结束时间" dataIndex="end_time" />
          <Column
            title="操作"
            render={(text, record) => (
              <span>
                <a>详情</a>
              </span>
            )}
          />
        </Table>
      </div>
    );
  

   
  }
  componentDidMount() {
    this.list();
	this.examadd()
	
  }

  // 数据接口
  async list() {
    const res = await _examList({});
    console.log(res);
	
    this.setState({
      list: res.data.exam,
    });

    
  }

//   数据列表详情接口
  async examadd(){
	  const res=await _examadd({})
	  console.log(res);
  }
}